﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;

using Maticsoft.Common;
using LTP.Accounts.Bus;
using DQYT.HTDZ.BLL;
using DQYT.HTDZ.Model;

namespace DQYT.HTDZ.Web.BDDTWELL
{
    public partial class Modify : Page
    {       

        protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					decimal ID=(Convert.ToDecimal(Request.Params["id"]));
					ShowInfo(ID);
				}
			}
		}
			
	private void ShowInfo(decimal ID)
	{
		BDDTWELLBLL bll=new BDDTWELLBLL();
		BDDTWELLModel model=bll.GetModel(ID);
		this.lblID.Text=model.ID.ToString();
		this.txtWELLID.Text=model.WELLID;
		this.txtJCRQ.Text=model.JCRQ.ToString();
		this.txtBX.Text=model.BX.ToString();
		this.txtCC.Text=model.CC.ToString();
		this.txtCCI.Text=model.CCI.ToString();
		this.txtRCYL.Text=model.RCYL.ToString();
		this.txtHS.Text=model.HS.ToString();
		this.txtRCYOL.Text=model.RCYOL.ToString();
		this.txtDYM.Text=model.DYM.ToString();
		this.txtCMD.Text=model.CMD.ToString();
		this.txtYY.Text=model.YY.ToString();
		this.txtTY.Text=model.TY.ToString();
		this.txtCYFS.Text=model.CYFS;
		this.txtBJ.Text=model.BJ;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtWELLID.Text.Trim().Length==0)
			{
				strErr+="WELLID不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtJCRQ.Text))
			{
				strErr+="JCRQ格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtBX.Text))
			{
				strErr+="BX格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtCC.Text))
			{
				strErr+="CC格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtCCI.Text))
			{
				strErr+="CCI格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtRCYL.Text))
			{
				strErr+="RCYL格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtHS.Text))
			{
				strErr+="HS格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtRCYOL.Text))
			{
				strErr+="RCYOL格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtDYM.Text))
			{
				strErr+="DYM格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtCMD.Text))
			{
				strErr+="CMD格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtYY.Text))
			{
				strErr+="YY格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtTY.Text))
			{
				strErr+="TY格式错误！\\n";	
			}
			if(this.txtCYFS.Text.Trim().Length==0)
			{
				strErr+="CYFS不能为空！\\n";	
			}
			if(this.txtBJ.Text.Trim().Length==0)
			{
				strErr+="BJ不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			decimal ID=decimal.Parse(this.lblID.Text);
			string WELLID=this.txtWELLID.Text;
			DateTime JCRQ=DateTime.Parse(this.txtJCRQ.Text);
			decimal BX=decimal.Parse(this.txtBX.Text);
			decimal CC=decimal.Parse(this.txtCC.Text);
			decimal CCI=decimal.Parse(this.txtCCI.Text);
			decimal RCYL=decimal.Parse(this.txtRCYL.Text);
			decimal HS=decimal.Parse(this.txtHS.Text);
			decimal RCYOL=decimal.Parse(this.txtRCYOL.Text);
			decimal DYM=decimal.Parse(this.txtDYM.Text);
			decimal CMD=decimal.Parse(this.txtCMD.Text);
			decimal YY=decimal.Parse(this.txtYY.Text);
			decimal TY=decimal.Parse(this.txtTY.Text);
			string CYFS=this.txtCYFS.Text;
			string BJ=this.txtBJ.Text;


			BDDTWELLModel model=new BDDTWELLModel();
			model.ID=ID;
			model.WELLID=WELLID;
			model.JCRQ=JCRQ;
			model.BX=BX;
			model.CC=CC;
			model.CCI=CCI;
			model.RCYL=RCYL;
			model.HS=HS;
			model.RCYOL=RCYOL;
			model.DYM=DYM;
			model.CMD=CMD;
			model.YY=YY;
			model.TY=TY;
			model.CYFS=CYFS;
			model.BJ=BJ;

			BDDTWELLBLL bll=new BDDTWELLBLL();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
